package com.xuxin.queue.presenter;

import com.xuxin.queue.bean.BaseBean;
import com.xuxin.queue.bean.PlayerBean;
import com.xuxin.queue.bean.QueueBean;
import com.xuxin.queue.contract.QueueContract;
import com.xuxin.queue.model.QueueModel;

/**
 * Created by xu_xin
 * Created on 2021/6/16 0016
 */
public class QueuePresenter implements QueueContract.Presenter {
    private final QueueModel model;
    private final QueueContract.View view;

    public QueuePresenter(QueueContract.View view) {
        this.view = view;
        model = new QueueModel();
    }

    @Override
    public void getQueuingInfo(String url) {
        if (null != model) {
            model.getQueuingInfo(this,url);
        }
    }

    @Override
    public void getPlayer(String url) {
        if (null != model) {
            model.getPlayer(this,url);
        }
    }

    @Override
    public void onSuccess(QueueBean queueBean) {
        if (null != view) {
            view.onSuccess(queueBean);
        }
    }

    @Override
    public void onSuccess(PlayerBean playerBean) {
        if (null != view) {
            view.onSuccess(playerBean);
        }
    }

    /**
     * 以下内容复用
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}